{__NOLAYOUT__}
<html><head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width">
    <title>小学赠品《全知识点普查彩图试卷》纸质版领取</title>
    <meta name="Keywords" content="">
    <meta name="Description" content="">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/css/queren.css" />
    <script type="text/javascript" src="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/js/layer_mobile/layer.js"></script>
    <link rel="stylesheet" type="text/css" href="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/css/layer.css" />
    <script src="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/js/jquery.1.9.1.js"></script>
    <script type="text/javascript" src="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/js/rem.js"></script>
    <script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
    <script type="text/javascript" src="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/js/address_select/mobileSelect.js"></script>
    <link rel="stylesheet" type="text/css" href="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/js/address_select/mobileSelect.css" />
</head>
<style>
    .dotm_btn1{background-color: #4876b2;}
    .huoqu{background-color: #4876b2;border-radius: 0!important;}
    .layui-m-layer-msg .layui-m-layercont{color: #fff;}
    textarea{resize: none;border: 1px solid #ccc;width: 98%;height: 1.3rem;appearance: none;-webkit-appearance: none;border-radius: 0;padding: 5px;}
    select#banben{width: 98%!important;color: #666!important;}
    .addressmone ul li input{height: 25px!important;line-height: 25px!important;padding: 0.35rem 0;color: #666;}
    .addressmone ul li span{color: #000;}
</style>
<body class="body_tj">
<div id="tbh5v0">
    <div class="addressmone">
        <ul>
            <li>
                <span>姓名</span><em><input type="text" name="consignee" value="" id="name" ></em>
            </li>
            <li>
                <span>手机号码</span><em><input style="width: 98%;height: 0.7rem;" type="number" pattern="[0-9]*" name="" id="tel" value="" /></em>
            </li>
            <li style="position: relative;">
                <span>验证码</span>
                <em><input style="width: 50%;height: 0.7rem;" type="number" name="" id="code" pattern="[0-9]*" value="" />
                    <div class="huoqu">获取验证码</div></em>
            </li>
            <li>
                <span>所在地区</span>
                <div id="trigger4" class="trigger4" style="text-indent:0.5em;display: inline-block;border: 1px solid #ccc;width: 73%;height: 35px;line-height: 35px;margin-left: 0.2rem;font-size: 12px;">
                    <span style="font-size: 12px;color: #666;">请选择</span>
                </div>
                <input type="hidden" name="" id="sheng" value="" />
                <input type="hidden" name="" id="shi" value="" />
                <input type="hidden" name="" id="xian" value="" />
            </li>
            <li>
                <span>邮寄地址</span><em> <textarea name="address" id="address_"></textarea></em>

            </li>
            <li>
                <span>在读年级</span>
                <em>
                    <select id="banben" value="">
                        <option value="0">请选择</option>
                        <option value="一年级">一年级</option>
                        <option value="二年级">二年级</option>
                        <option value="三年级">三年级</option>
                        <option value="四年级">四年级</option>
                        <option value="五年级">五年级</option>
                        <option value="六年级">六年级</option>
                    </select>
                </em>
            </li>
        </ul>

        <div class="dotm_btn">
            <input type="submit" value="纸质版领取需自付7元快递费用" class="dotm_btn1">
        </div>

    </div>
</div>
<script type="text/javascript" charset="utf-8">
  wx.config({$jssdk});
</script>
<script>
  $(function(){
    var mobileSelect4 = new MobileSelect({
      trigger: '#trigger4',
      title: '地区选择',
      wheels: [{data:[
          {
            id:'1',
            value:'',
            childs:[
              {id:'A1',value:''},
            ]
          }
        ]}],
      transitionEnd:function(indexArr, data){

      },
      callback:function(indexArr, data){
        console.log(data);
        $('#sheng').val(data[0].id);
        $('#shi').val(data[1].id);
        $('#xian').val(data[2].id);
      }
    });
    $.ajax({
      type: "get",
      url: "http://oa.fc62.com/api/ajax/area",
      dataType: "json",
      success: function(res){
        mobileSelect4.updateWheels(res.data);
      }
    });
    $('.huoqu').click(function() {
      var tel = $('#tel').val();
      if(!(/^1[3456789]\d{9}$/.test(tel))) {
        layer.open({
          content: '请输入正确的手机号码',
          skin: 'msg',
          time: 2 //2秒后自动关闭
        });
        return false;
      }
      $.ajax({
        type: 'get',
        url:"http://oa.fc62.com/api/Pep/tel/tel/"+tel ,
        success: function(data){
          if(data.code == 0) {
            layer.open({
              content: data.msg,
              skin: 'msg',
              time: 2 //2秒后自动关闭
            });
            return false
          }else{
            $.ajax({
              type: 'post',
              url:"/api/sms/send" ,
              data:{mobile:tel,action:'default'},
              success: function(data){
                console.log(data);
                if(data.code != 1){
                  layer.open({
                    content:data.msg ,
                    skin: 'msg',
                    time: 2 //2秒后自动关闭
                  });
                  return false
                }else{
                  var count = 120;
                  const countDown = setInterval(() => {
                    if (count === 0) {
                      $('.huoqu').text('重新发送').removeAttr('disabled');
                      $('.huoqu').css({
                        background: '#f3494c',
                        color: '#fff',
                      });
                      clearInterval(countDown);
                    } else {
                      $('.huoqu').attr('disabled', true);
                      $('.huoqu').css({
                        background: '#eee',
                        color: '#333',
                      });
                      $('.huoqu').text(count + '秒后可重新获取');
                    }
                    count--;
                  }, 1000);
                }
              }
            });
          }
        }
      });

    });
    $('.dotm_btn1').click(function(){
      var name = $('#name').val();
      var address = $('#address_').val();
      var tel = $('#tel').val();
      var code = $('#code').val();
      var sheng = $('#sheng').val();
      var shi = $('#shi').val();
      var xian = $('#xian').val();
      var banben = $('#banben').val();
      if(name == ""||name == null){
        layer.open({
          content: '请填写姓名',
          skin: 'msg',
          time: 2 //2秒后自动关闭
        });
        return false;
      }

      if(!(/^1[3456789]\d{9}$/.test(tel))) {
        layer.open({
          content: '请输入正确的手机号码',
          skin: 'msg',
          time: 2 //2秒后自动关闭
        });
        return false;
      }
      if(code == ""||code == null){
        layer.open({
          content: '请填写验证码',
          skin: 'msg',
          time: 2 //2秒后自动关闭
        });
        return false;
      }
      if(sheng == ""||sheng == null){
        layer.open({
          content: '请选择所在地区',
          skin: 'msg',
          time: 2 //2秒后自动关闭
        });
        return false;
      }
      if(address == ""||address == null){
        layer.open({
          content: '请填写详细地址',
          skin: 'msg',
          time: 2 //2秒后自动关闭
        });
        return false;
      }
      if(banben == 0){
        layer.open({
          content: '请选择在读年级',
          skin: 'msg',
          time: 2 //2秒后自动关闭
        });
        return false;
      }
      //验证验证码
      $.ajax({
        type: 'post',
        url:"/api/sms/check" ,
        data:{mobile:tel,captcha:code},
        success: function(data){
          if(data.code == 0){
            layer.open({
              content: data.msg,
              skin: 'msg',
              time: 2,
            });
            return false;
          }else{
            $.ajax({
              type: 'post',
              url:"/api/pep/index" ,
              data:{name:name,phone:tel,address:address,shen:sheng,shi:shi,xian:xian,version:banben},
              success: function(data){
                if(data.code != 0){
                  wx.chooseWXPay({
                    timestamp: data.data.timeStamp,
                    nonceStr: data.data.nonceStr,
                    package: data.data.package,
                    signType: data.data.signType,
                    paySign: data.data.paySign, // 支付签名
                    success: function (res) {
                    // 支付成功后的回调函数
                      if (res.errMsg == "chooseWXPay:ok") {
                        // alert('支付成功');
                        window.location.href="http://tmall.fc62.com/sxlq_success.html";
                        // window.location.reload();
                      } else {
                        alert(res.errMsg,null);
                        window.location.reload();
                      }
                  },
                    cancel: function(r) {
                      alert('取消支付');
                      window.location.reload();
                    },
                    fail:function(r){
                      alert('支付失败了');
                      window.location.reload();
                      //支付失败
                    }

                });
                  // layer.open({
                  //   content: data.msg,
                  //   skin: 'msg',
                  //   time: 2, //2秒后自动关闭
                  //   end:function(){
                  //     window.location.reload()
                  //   }
                  // });
                  //调取微信支付 6元
                  window.location.reload();
                }else{
                  layer.open({
                    content: data.msg,
                    skin: 'msg',
                    time: 2, //2秒后自动关闭
                  });
                  window.location.reload();
                }

              }
            });
          }
        }
      });


    });
  });




</script>
</body>

</html>